
#ifndef __LLD_VBI_M3327_H__
#define __LLD_VBI_M3327_H__

#include <sys_config.h>
#include <osal/osal.h>
#include <basic_types.h>
#include <Mediatypes.h>

#include <hld/hld_dev.h>
#include <hld/vbi/vbi.h>
#include <hld/vbi/vbi_dev.h>
#include <hld/dis/vpo.h>

#ifdef VBI_DEBUG
#define VBI_ASSERT        	 ASSERT
#define VBI_PRINTF	        libc_printf
#define CCDEC_PRITNF       libc_printf
#else
#define VBI_ASSERT(...)	  do{}while(0)
#define VBI_PRINTF(...)	  do{}while(0)
#define CCDEC_PRINTF(...)  do{}while(0)
#endif


struct VBIDataHdr 
{
	BOOL bInfoValid;
	
	UINT8 uPesStart;
	// Bit map to specify which parameter in the structure is valid: "1" valid, "0" not invlid .
	// Bit0: STC_ID section valid or not;
	// bit1: Data discontinue or not
	// Bit2: PTS section valid or not;
	// Bit3: uVobuNum and uVobuBaseTime section valid or not.
	// Bit4: Video trick mode or not
	
	//UINT8	uCtrlByte; 
	UINT8	uStcId;	// System timer counter identify:0: STC 0;1: STC 1;
	UINT32	uPTS;	// Corresponding PTS value for a data block.

	UINT8* puStartPoint;
	UINT32 uDataSize; 	// data size 
};

#define VBI_QUEUE_DEPTH	600//500//400//300

struct vbi_m3327_private
{
	void *priv_addr;
	UINT8 status;

	struct VBIDataHdr  InitHdr; 
	struct VBIDataHdr* pVBIWrHdr; 
	struct VBIDataHdr* pVBIRdHdr;	
	
	UINT32	uRemainDataSize;				
	UINT8*	puRemainDataPtr ;
	UINT8	uNotEnoughDataFlag;

	struct vbi_config_par config_par;
	UINT8	ttx_by_osd;/*TURE : display ttx by OSD*/
	UINT8	cc_by_osd;/*dispaly atsc cc by OSD, 0:off*/ /*!=0xff:dispaly,  */
	UINT16	dtvcc_by_osd;/*dispaly atsc dtv cc by OSD, 0:off*/ /*!0xff:dispaly, */ //hbchen
	void 	(*init_ttx_decoder)(void);
	void		(*init_cc_decoder)(struct vbi_device *dev);
	BOOL      (*vbi_line21_push_by_cc)(UINT16 data);
	BOOL      (*vbi_line21_push_by_dtvcc)(UINT16 data);	//xing 20070522 for DTVCC 
};
/*for cc/dtvcc/eas using==================*/
void ccvbi_m3327_setoutput(struct vbi_device *dev,T_VBIRequest *pVBIRequest);	//vicky20101229 dbg rename
INT32 vbi_cc_open(struct vbi_device *dev);
void cc_parsing(void);
void cc_parsing_dtvcc(void);
void eas_text_scroll();
BOOL vbi_line21_push(UINT16 data);
BOOL vbi_line21_push_dtvcc(UINT16 data);
void vbi_m3327_init_cc_decoder(struct vbi_device *dev);
/*===============================*/

#endif /*__LLD_VBI_M3327_H__ */
